Motion estimation and motion compensation are important technologies for video compression. A considerable part of bits in a compressed video bit-stream are used to transmit motion vector information. Motion information of a block may include a prediction direction, a motion vector, and reference frame information of the block. The reference frame information may represent a frame or frames that are referenced for obtaining the block. In cases of a low bit rate, especially for a high-definition video, bits consumed to transmit motion vector information generally account for over 50% of the total number of bits in a bitstream. Therefore, it is very important to efficiently encode the motion information.
At present, inter-frame prediction technologies for improving motion prediction/compensation mainly include a decoder motion vector derivation technology and a motion vector integration technology.
In the decoder motion vector derivation technology, an encoder and a decoder need to process a block by using the same search/derivation mechanism in a large range. With respect to a block that is encoded by the encoder according to this technology, the decoder restores the block by using a specific search/derivation mechanism in a large range. For example, by fully using correlation between a block and an adjacent encoded (or decoded) region in a current frame where the block is located, or using correlation between a block and previous and next adjacent encoded (or decoded) frames of the current frame where the block is located, decoding is performed by performing search/derivation in a large range. This method may achieve high compression performance; however, the encoder and the decoder need to perform search/derivation in a large range of image frames, which is highly complex in calculation.
In the motion vector integration technology, by using strong correlation between a motion vector of a current block and a motion vector of a neighboring block, a motion vector of a closest neighboring block may be used to replace the motion vector of the current block, so that an index value of the neighboring block is used to replace the motion vector of the current block during encoding to reduce encoded bits, where the neighboring block is an optimal integrated candidate block of the current block. A neighboring block of the current block refers to a block whose position is any one of the following positions: corresponding positions in previous and next adjacent frames of the current block, an upper side of the current block, a left side of the current block, an upper-left corner of the current block, and an upper-right corner of the current block. In the prior art, circumstances under which the motion vector integration technology may be used are disclosed, and how to determine the optimal integrated candidate block of the current block is also disclosed. In a case where the motion vector integration technology can be used, an encoder determines one of neighboring blocks as an optimal integrated candidate block for a current block, uses a motion vector thereof to replace a motion vector of the current block, and transmits an index value of position information of the optimal integrated candidate block as the encoding information of the current block to a decoder; the decoder determines the motion vector of the current block according to the index value to find a reference block of the current block, thereby determining a predicted value of motion compensation of the current block.
In the motion vector integration technology, by using the encoding index value instead of the motion vector of the current block, encoding efficiency may be improved; however, the motion vector of the current block is not exactly the same as the motion vector of the neighboring block, and there is a big error if the motion vector of the neighboring block is directly used to replace the motion vector of the current block; consequently, accuracy of motion compensation decreases, image compression is affected, and encoding quality of an image deteriorates.
Although the encoder may encode a motion vector difference existing between the motion vector of the current block itself and the motion vector of the optimal integrated candidate block in a case where the motion vector of the current block is replaced with the motion vector of the optimal integrated candidate block, so as to correct the motion vector of the current block on the decoder, the encoded motion vector difference may occupy a large number of bits in an encoded bit stream, which affects encoding efficiency. Although the encoder may also encode a residual between the motion vector of the optimal integrated candidate block for the current block and an original value of the current block, transmit the residual to the decoder for correction, because the residual between the motion vector of the optimal integrated candidate block for the current block and the original value of the current block is large, the residual may occupy a large number of bits in the encoded bit stream, which also affects encoding efficiency.